﻿using System;
using CommonUtility.Utility;
using System.Data;
using System.Collections.Generic;

namespace UIDevCore
{
    public class PostData
    {
        public String No { get; set; }
        //public String ClientID { get; set; }
        public String Body { get; set; }
    }

    public class ResponseData
    {
        public String Body { get; set; }
        public String Error { get; set; }
        public String Client
        {
            get {
                UIPremission pre = new UIPremission();
                if (pre.IsLogin)
                    return JsonHelper.SerializeData(pre.CurrentUser);
                return null;
            }
        }
        public DateTime CurrentDate { get { return DateTime.Now; } }
        public short ErrorType { get; set; }
    }

    public class ResponseListData
    {
        public int total { set; get; }
        public string rows { set; get; }
    }

    public class PostListSetting
    {
        public string Where { set; get; }
        public int PageIndex { set; get; }
        public int PageSize { set; get; }
        public string Sort { set; get; }

        public bool HasCondition
        {
            get { return this.Conditions != null && this.Conditions.Count > 0; }
        }
        
        public Dictionary<String, Object> Conditions
        {
            get
            {
                if (this.Where == null || this.Where == string.Empty)
                    return null;
                else
                    return JsonHelper.DeserializeData<Dictionary<String, Object>>(this.Where);
            }
        }
    }
}
